import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/page/home/Home'
import Location  from '@/page/location/Location'
import Detail from '@/page/detail/Detail'
import detailGalary from '@/page/detail/components/detailGalary'
import mapContent from '@/page/detail/components/mapContent'
import wode from '@/page/wode/wode'
import retiu from '@/page/retiu/retiu'
import xiaox from '@/page/xiaox/xiaox'
import mapy from '@/page/mapy/mapy'
import login from '@/page/login/login'
import wodeShez from '@/page/wode/components/wodeShez'
import wodeDingd from '@/page/wode/components/wodeDingd'
Vue.use(Router)

export default new Router({
 
  routes: [
    {
      path: '/',
     
      component: Home
    }, 
    {
      path: '/location',
     
      component : Location
    },
    {
      path: '/detail/:id',
     
      component : Detail,
      children:[
        {
          path:"galary",
          component:detailGalary
        },
        {
          path:"map",
          component:mapContent
        } 
      ]
    },
    
    {
      path:"/mapy",
      component:mapy
    },
    {
      path:"/wode",
      component:wode
    },
    {
      path:"/wodeShez",
      component:wodeShez
    },
    {
      path:"/wodeDingd",
      component:wodeDingd
    },

     {
      path:'/retiu:aid',
      component:retiu,
      meta:{
        flag:true
      },
      beforeEnter:(function(to,from,next){
        
        if ( !to.matched.some(function(item){ return item.meta.flag }))
        {
          next('/login')	
         }    else{
         next()
           }
    })
    },
    {
      path:'/retiu',
      component:retiu,  
    },
    {
      path:"/xiaox",
      component:xiaox,
      meta:{
        // flag:1
      },
     
      beforeEach:(function(to,from,next){
           let login = store.state.login
        if (login)
        {
          next('/login')	
      }    else{
         next()
           }
    })

    },
    {
      path:"/login",
      component:login,
      name:"login"
    }
     
  ],

  
})
